/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tcloudclient.actionManager;

import api.action.ActionTypeEnum;
import api.action.crates.Client.NewUpdateFolderCrate;
import tcloudclient.Utils;
import java.io.File;

/**
 *
 * @author Tomas
 */
public class NewFolderActionExecutor implements ExecuteActionInterface<NewUpdateFolderCrate> {

    @Override
    public void execute(NewUpdateFolderCrate actionData, FireActionExecuteInterface event) {
        if (event.canActionExecute(actionData.getPath(), actionData.getVersion(), tcloudclient.actionManager.ActionTypeClientEnum.NEW)) {
            String generatePaht = Utils.generatePaht(actionData.getPath());

            if ((new File(generatePaht)).mkdir()) {
                event.actionExecuted(actionData.getPath(), actionData.getVersion(), tcloudclient.actionManager.ActionTypeClientEnum.NEW);
            }
        }

    }

    @Override
    public boolean isSupported(ActionTypeEnum actionType) {
        return actionType == ActionTypeEnum.NEW_FOLDER;
    }
}
